#回合制对战游戏
#角色，房间，战斗
import random
class Role(object):
   def __init__(self,name,sex,blood=100):
      self.name = name
      self.sex = sex
      self.blood = blood
      self.room = None
   def attach(self,other):
      fight = {10:"attack",0:"has be invalid of"}
      if self == other:
         print("no yourself")
      else:
         if self.room and self.room == other.room:
            if self.blood <= 0:
               print("you die")
            else:
               if random.choice([0,1]) == 0:
                  lost_blood = 10
                  print(f"{other.name} has no equipment")
               else:
                  lost_blood = 0
                  print(f"{other.name} wear a equipment")
               other.blood = other.blood - lost_blood
               print(f"{self.name} {fight[lost_blood]} {other.name} to subtract {lost_blood} HP, now HP : {other.blood}")
               if other.blood <= 0:
                  print(f"{other.name} you die")
                  exit()
         else:
            print("place wrong")
class Room(object):
#  MAX = 2
   def __init__(self,name):
      self.name = name
      self.member_list = []
   def add_member(self,role):
      if role.room == None:
         if len(self.member_list) < 2:
            self.member_list.append(role)
            role.room = self
            print(f"{role.name} succeed to take part in {self.name} room")
      else:
         print(f"{role.name} succees to takr part in {role.room.name} room")
print('''=================================
1.make a role
2.build a room
3.join a room
4.VS
5.quit
=============================''')
roles = dict()
rooms = dict()
while True:
   enter_number = input("what do you want:\n")
   if enter_number.isdigit():
      enter_number = int(enter_number)
      if 1 <= enter_number <= 5:
         if enter_number == 1:
            name,sex = input("your name and sex , space please:\n").split()
            roles[name] = Role(name,sex)
         elif enter_number == 2:
            room = input("room number\n")
            rooms[room] = Room(room)
         elif enter_number == 3:
            print(f"role{roles.keys()},room{rooms.keys()}")
            role_name,room_name = input("your role and the room:\n").split()
            rooms[room_name].add_member(roles[role_name])
         elif enter_number == 4:
            while True:
               enter = random.choice([0,1])
               if enter == 0:
                  rooms[room_name].member_list[0].attach(rooms[room_name].member_list[1])
               else:
                  rooms[room_name].member_list[1].attach(rooms[room_name].member_list[0])
      else:
         print("1~5 please")
   else:
      print("something wrong , again please")